]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Support (fallback) app menu in SSD
authorFlorian Müllner <fmuellner@gnome.org>
Sat, 24 May 2014 01:32:44 +0000 (03:32 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Tue, 27 May 2014 17:49:05 +0000 (19:49 +0200)
We now allow "appmenu" in the button layout to make synchronizing it
with GTK+'s client-side decorations easier, but as some people tweak
their settings to get in-window app menus even when using the shell,
actually pop up the app menu when the button is activated.

https://bugzilla.gnome.org/show_bug.cgi?id=730752

js/ui/windowManager.js
js/ui/windowMenu.js
src/gnome-shell-plugin.c
src/shell-wm-private.h
src/shell-wm.c

index 8121dc0be43f7379f1dd95819aaea4b9a3e84177..401db757414bdafcc33ef284c0791b6cfb8dba79 100644 (file)
@@ -1163,8 +1163,8 @@ const WindowManager = new Lang.Class({
         this._tilePreview.hide();
     },
 
-    _showWindowMenu: function(shellwm, window, x, y) {
-        this._windowMenuManager.showForWindow(window, x, y);
+    _showWindowMenu: function(shellwm, window, menu, x, y) {
+        this._windowMenuManager.showWindowMenuForWindow(window, menu, x, y);
     },
 
     _startAppSwitcher : function(display, screen, window, binding) {
index 3dc85c6633af634bf8b2c2aa87fab48e925e899c..c6dc7295888e8a9e1c3fbbb9595273ae3b88c708 100644 (file)
@@ -9,6 +9,7 @@ const Shell = imports.gi.Shell;
 const BoxPointer = imports.ui.boxpointer;
 const Main = imports.ui.main;
 const PopupMenu = imports.ui.popupMenu;
+const RemoteMenu = imports.ui.remoteMenu;
 
 const WindowMenu = new Lang.Class({
     Name: 'WindowMenu',
@@ -122,6 +123,22 @@ const WindowMenu = new Lang.Class({
     }
 });
 
+const AppMenu = new Lang.Class({
+    Name: 'AppMenu',
+    Extends: RemoteMenu.RemoteMenu,
+
+    _init: function(window) {
+        let app = Shell.WindowTracker.get_default().get_window_app(window);
+
+        this.parent(Main.layoutManager.dummyCursor, app.menu, app.action_group);
+
+        this.actor.add_style_class_name('fallback-app-menu');
+
+        Main.layoutManager.uiGroup.add_actor(this.actor);
+        this.actor.hide();
+    }
+});
+
 const WindowMenuManager = new Lang.Class({
     Name: 'WindowMenuManager',
 
@@ -129,8 +146,10 @@ const WindowMenuManager = new Lang.Class({
         this._manager = new PopupMenu.PopupMenuManager({ actor: Main.layoutManager.dummyCursor });
     },
 
-    showForWindow: function(window, x, y) {
-        let menu = new WindowMenu(window);
+    showWindowMenuForWindow: function(window, type, x, y) {
+        let menu = (type == Meta.WindowMenuType.WM) ? new WindowMenu(window)
+                                                    : new AppMenu(window);
+
         this._manager.addMenu(menu);
 
         Main.layoutManager.setDummyCursorGeometry(x, y, 0, 0);
@@ -140,5 +159,5 @@ const WindowMenuManager = new Lang.Class({
             if (!isOpen)
                 menu.destroy();
         }));
-    },
+    }
 });
index 618a0682b738f45a696c768178f65e91256a3079..4b78870f68b0e394fcd370518eed6c6cd667afbf 100644 (file)
@@ -73,10 +73,11 @@ static void gnome_shell_plugin_show_tile_preview (MetaPlugin      *plugin,
                                                   MetaRectangle   *tile_rect,
                                                   int              tile_monitor);
 static void gnome_shell_plugin_hide_tile_preview (MetaPlugin *plugin);
-static void gnome_shell_plugin_show_window_menu  (MetaPlugin *plugin,
-                                                  MetaWindow *window,
-                                                  int         x,
-                                                  int         y);
+static void gnome_shell_plugin_show_window_menu  (MetaPlugin         *plugin,
+                                                  MetaWindow         *window,
+                                                  MetaWindowMenuType  menu,
+                                                  int                 x,
+                                                  int                 y);
 
 static gboolean              gnome_shell_plugin_xevent_filter (MetaPlugin *plugin,
                                                                XEvent     *event);
@@ -308,12 +309,13 @@ gnome_shell_plugin_hide_tile_preview (MetaPlugin *plugin)
 }
 
 static void
-gnome_shell_plugin_show_window_menu (MetaPlugin *plugin,
-                                     MetaWindow *window,
-                                     int         x,
-                                     int         y)
+gnome_shell_plugin_show_window_menu (MetaPlugin         *plugin,
+                                     MetaWindow         *window,
+                                     MetaWindowMenuType  menu,
+                                     int                 x,
+                                     int                 y)
 {
-  _shell_wm_show_window_menu (get_shell_wm (), window, x, y);
+  _shell_wm_show_window_menu (get_shell_wm (), window, menu, x, y);
 }
 
 static gboolean
index d5c02e5cc1ec0cd70abc8aa33987a4248cdb5359..c7068efa5c66612d9962faa075852d09dd89b211 100644 (file)
@@ -42,6 +42,7 @@ void _shell_wm_show_tile_preview     (ShellWM             *wm,
 void _shell_wm_hide_tile_preview     (ShellWM             *wm);
 void _shell_wm_show_window_menu      (ShellWM             *wm,
                                       MetaWindow          *window,
+                                      MetaWindowMenuType   menu,
                                       int                  x,
                                       int                  y);
 
index 50ecb7e7a4466cb29e6d8b9273d3ee7ec6045d31..928f5f1046547626ece1722e89d97628793bd82b 100644 (file)
@@ -141,8 +141,8 @@ shell_wm_class_init (ShellWMClass *klass)
                   G_TYPE_FROM_CLASS (klass),
                   G_SIGNAL_RUN_LAST,
                   0, NULL, NULL, NULL,
-                  G_TYPE_NONE, 3,
-                  META_TYPE_WINDOW, G_TYPE_INT, G_TYPE_INT);
+                  G_TYPE_NONE, 4,
+                  META_TYPE_WINDOW, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
   shell_wm_signals[FILTER_KEYBINDING] =
     g_signal_new ("filter-keybinding",
                   G_TYPE_FROM_CLASS (klass),
@@ -297,12 +297,13 @@ _shell_wm_hide_tile_preview (ShellWM *wm)
 }
 
 void
-_shell_wm_show_window_menu (ShellWM    *wm,
-                            MetaWindow *window,
-                            int         x,
-                            int         y)
+_shell_wm_show_window_menu (ShellWM            *wm,
+                            MetaWindow         *window,
+                            MetaWindowMenuType  menu,
+                            int                 x,
+                            int                 y)
 {
-  g_signal_emit (wm, shell_wm_signals[SHOW_WINDOW_MENU], 0, window, x, y);
+  g_signal_emit (wm, shell_wm_signals[SHOW_WINDOW_MENU], 0, window, menu, x, y);
 }
 
 void